<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Fit Layout</title>
    <meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
    <script src="../../../scripts/jquery.min.js"></script>
    <script src="../../../scripts/miniui/miniui.js"></script>
    <link href="../../../scripts/miniui/themes/default/miniui.css" rel="stylesheet">
    <link href="../../../scripts/miniui/themes/icons.css" rel="stylesheet">
    <link href="../../../scripts/miniui/themes/pure/skin.css" rel="stylesheet">
    <script src="../../../scripts/core.js"></script>

</head>
<body>
<style type="text/css">
    html, body {
        margin: 0;
        padding: 0;
        border: 0;
        width: 100%;
        height: 100%;
        overflow: hidden;
    }
</style>
<div class="mini-toolbar" style="padding:2px;border-bottom:0;">
    <table style="width:100%;">
        <tr>
            <td style="width:100%;">

                <a class="mini-button" iconCls="icon-filter" onclick="batchActiveTron()" plain="true">激活钱包</a>
                <a class="mini-button" iconCls="icon-date" onclick="batchTransferTron()" plain="true">归集USDT</a>
                <a class="mini-button" iconCls="icon-find" onclick="add()" plain="true">人工添加U币</a>
            </td>
        </tr>
    </table>
</div>
<!--撑满页面-->
<div class="mini-fit">

    <mini-datagrid _dataField="data111" allowCellEdit="true" allowCellSelect="true"
                   allowResize="true" allowSortColumn="false"
                   class="mini-datagrid"
                   id="datagrid1" idField="id" multiSelect="true"
                   pageSize="100" showSortIcon="true"
                   style="width:100%;height:100%;"
                   url="/usdt/tron/getAllTx">
        <columns>
            <column type="indexcolumn"></column>
            <column field="name" width="100">名称
            </column>
            <column field="val" width="100">数值
            </column>

        </columns>
    </mini-datagrid>

</div>

<script type="text/javascript">

    var auth = GetParams()
    mini.parse();
    var grid = mini.get("datagrid1");
    grid.setAjaxOptions({
        headers: {"userId": auth.userId, "token": auth.token}
    });


    grid.load();

    function add() {

        mini.open({
            targetWindow: window,
            url: "AddUSDT.html?userId=" + auth.userId + "&token=" + auth.token,
            title: "新增",
            width: 600,
            height: 400,
            onload: function () {

            },
            ondestroy: function (action) {

                grid.reload();
            }
        });
    }

    function batchActiveTron() {

        $.ajax({
            url: "/usdt/tron/batchActiveTron",
            data: {},
            type: "post",
            contentType: 'application/json',
            headers: {"userId": auth.userId, "token": auth.token},
            success: function (text) {
                var resp = mini.decode(text)
                if (resp.code == 200) {
                    //grid.reload();
                } else {
                    //mini.alert("错误码:" + resp.code);
                }

            },
            error: function (jqXHR, textStatus, errorThrown) {
                alert(jqXHR.responseText);
            }
        });

    }

    function batchTransferTron() {

        $.ajax({
            url: "/usdt/tron/batchTransferTron",
            data: {},
            type: "post",
            contentType: 'application/json',
            headers: {"userId": auth.userId, "token": auth.token},
            success: function (text) {
                var resp = mini.decode(text)
                if (resp.code == 200) {
                    grid.reload();
                } else {
                    mini.alert("错误码:" + resp.code);
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {
                alert(jqXHR.responseText);
            }
        });

    }

    function copyElementIdToClipboard(address) {
        try {
            // 复制到剪贴板
            navigator.clipboard.writeText(address)
                .then(() => {

                })
                .catch(err => {
                    console.error('复制失败:', err);

                });

            return true;
        } catch (error) {
            console.error('操作出错:', error);
            return false;
        }
    }

    function search() {
        var key = mini.get("key").getValue();
        var obj = mini.get("withdrawStatus");

        grid.load({
            status: obj.getValue(),
            BTC: 1
        });
    }
</script>

</body>
</html>